<template>
  <a-card :bordered="false">

    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="12">
          <a-col :md="7" :sm="8">
            <a-form-item label="请求时间" :label-col="{span: 6}" :wrapper-col="{span: 14, offset: 1}">
              <a-input v-model="queryParam.dictName" placeholder="请输入请求时间" />
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <a-form-item label="请求方法" :label-col="{span: 6}" :wrapper-col="{span: 14, offset: 1}">
              <a-input v-model="queryParam.dictCode" placeholder="请输入请求方法" />
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
              <a-button type="primary" icon="reload" style="margin-left: 8px" @click="searchReset">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <a-table
      ref="table"
      row-key="id"
      size="middle"
      :columns="columns"
      :data-source="dataSource"
      :pagination="pagination"
      :loading="loading"
      @change="handleTableChange"
      class="j-table-force-nowrap"
    >
      <template slot="htmlSlot" slot-scope="text">
        <div v-html="text" />
      </template>

    </a-table>
  </a-card>
</template>

<script>
import { TableListMixin } from '@/mixins/TableListMixin'

export default {
  name: 'ArticleList',
  mixins: [TableListMixin],
  data() {
    return {
      description: '文章管理',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 120,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '请求时间',
          align: 'center',
          dataIndex: 'time'
        },
        {
          title: '请求方法',
          align: 'center',
          dataIndex: 'method'
        },
        {
          title: '请求地址',
          align: 'center',
          dataIndex: 'path'
        },
        {
          title: '响应状态',
          align: 'center',
          dataIndex: 'status'
        },
        {
          title: '请求耗时',
          align: 'center',
          dataIndex: 'timeTaken'
        }
      ],
      url: {
        list: '/httpTraceLog/list'
      }
    }
  },
  methods: {
    handleEdit(record) {
      this.$router.push({
        path: '/article/publish',
        query: {
          articleData: record
        }
      })
    },
    handlePreview(record) {
      this.$refs.previewModal.preview(record)
      this.$refs.previewModal.title = '详情'
      this.$refs.previewModal.disableSubmit = true
    }
  }
}
</script>
